<?php

/**
 * 无限极分类
 * @param $data
 * @param int $pid
 * @param int $level
 * @return array
 */
function getTree($data, $pid = 0, $level = 0)
{
    static $arr = array();
    foreach ($data as $k => $v) {
        if ($v['pid'] == $pid) {
            $v['level'] = $level;
            $arr[]      = $v;
            getTree($data, $v['id'], $level + 1);
        }
    }
    return $arr;
}


/**
 *
 */
function getTypeName($tag)
{
    //1新留言  2意向客户 3已处理
    $list = [
        1 => "新留言",
        2 => "意向客户",
        3 => "已处理",
    ];
    return isset($list[$tag]) ? $list[$tag] : "无";


}


function getProGressName($tag)
{
    $list = [
        1 => "初审",
        2 => "复审",
        3 => "财务",
    ];
    return isset($list[$tag]) ? $list[$tag] : "无";
}

function getWithDrawStatus($tag)
{
    $list = [
        1 => "待审核",
        2 => "审核不通过",
        3 => "审核通过",
    ];
    return isset($list[$tag]) ? $list[$tag] : "无";
}

function getProGressPercent($tag, $status = 0)
{
    $list = [
        1 => "33.33%",
        2 => "66.66%",
        3 => "100%",
    ];
    if ($tag == 3 && $status > 1) {
        return '100%';
    }

    return isset($list[$tag - 1]) ? $list[$tag - 1] : "0%";
}


function getWithDrawWay($tag)
{
    $list = [
        1 => "微信",
        2 => "支付宝",
        3 => "银联",
    ];
    return isset($list[$tag]) ? $list[$tag] : "无";
}

function getWithStatus($tag)
{
    $list = [
        0 => "未到账",
        1 => "已到账",
    ];
    return isset($list[$tag]) ? $list[$tag] : "无";
}

function daysbetweendates($date1, $date2)
{
    $date1 = strtotime($date1);
    $date2 = strtotime($date2);
    $days  = ceil(abs($date1 - $date2) / 86400);
    return (int)$days;
}

function getDay7TimeStamps($date2, $i)
{
    $t = strtotime("$date2 -$i day");
//    $t = strtotime("$i days ago");
//开始时间戳
    $data['firstday'] = mktime(0, 0, 0, date("m", $t), date("d", $t), date("Y", $t));
//结束时间戳
    $data['lastday'] = mktime(23, 59, 59, date("m", $t), date("d", $t), date("Y", $t));
    return $data;
}






